using System;
using FytSoa.Common.Utils;
using System.ComponentModel.DataAnnotations;
using FytSoa.Common.Enum;
using SqlSugar;

namespace FytSoa.Application.Erp;

/// <summary>
/// erp-产品入库
/// </summary>
public class ErpInstockDto : AppEntity
{
    /// <summary>
    /// 入库编号
    /// </summary>
    public string Number { get; set; }

    /// <summary>
    /// 入库类型(1=采购2=生产3=销售退货4=其他)
    /// </summary>
    [Required]
    public ErpInStockTypeEnum Type { get; set; } = ErpInStockTypeEnum.Purchase;

    /// <summary>
    /// 关系编号(采购/生产/销售退货)
    /// </summary>
    [Required]
    public long RelationId { get; set; } = 0;
    
    /// <summary>
    /// 关系内容
    /// </summary>
    public ErpInstockRelationDto Relation { get; set; } = new ();

    /// <summary>
    /// 仓库编号
    /// </summary>
    [Required]
    public long WarehouseId { get; set; } = 0;

    /// <summary>
    /// 仓库信息
    /// </summary>
    public ErpWarehouseSimpleDto Warehouse { get; set; } = new();

    /// <summary>
    /// 入库时间
    /// </summary>
    [Required]
    public DateTime InStockTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 产品集合编号
    /// </summary>
    public List<long> ProductIds { get; set; } = new();
    
    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    public ErpAuditEnum Status { get; set; } = 0;
    
    /// <summary>
    /// 审批流程
    /// </summary>
    [Required]
    public long FlowId { get; set; } = 0;

    /// <summary>
    /// 审批流程详情
    /// </summary>
    [Required]
    public ErpFlowDto.ErpFlowSimpleDto Flow { get; set; } = new();

    /// <summary>
    /// 备注
    /// </summary>
    public string Remark { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }


}

/// <summary>
/// 关系对象
/// </summary>
public class ErpInstockRelationDto
{
    public long Id { get; set; }

    public string Number { get; set; }
}